sgdk: vdp.h Source File

sgdk

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

vdp.h
Go to the documentation of this file.

    00001
    00014 #ifndef _VDP_H_
    00015 #define _VDP_H_
    00016
    00017
    00018 #include "font.h"
    00019
    00020
    00025 #define GFX_DATA_PORT           0xC00000
    00026
    00030 #define GFX_CTRL_PORT           0xC00004
    00031
    00035 #define GFX_HVCOUNTER_PORT      0xC00008
    00036
    00037
    00042 #define VDP_FIFOEMPTY_FLAG      (1 << 9)
    00043
    00047 #define VDP_FIFOFULL_FLAG       (1 << 8)
    00048
    00052 #define VDP_VINTPENDING_FLAG    (1 << 7)
    00053
    00057 #define VDP_SPROVERFLOW_FLAG    (1 << 6)
    00058
    00062 #define VDP_SPRCOLLISION_FLAG   (1 << 5)
    00063
    00067 #define VDP_ODDFRAME_FLAG       (1 << 4)
    00068
    00072 #define VDP_VBLANK_FLAG         (1 << 3)
    00073
    00077 #define VDP_HBLANK_FLAG         (1 << 2)
    00078
    00082 #define VDP_DMABUSY_FLAG        (1 << 1)
    00083
    00087 #define VDP_PALMODE_FLAG        (1 << 0)
    00088
    00094 #define WINDOW                  window_adr
    00095
    00098 #define WPLAN                   WINDOW
    00099
    00104 #define HSCRL                   hscrl_adr
    00105
    00110 #define SLIST                   slist_adr
    00111
    00116 #define APLAN                   aplan_adr
    00117
    00122 #define BPLAN                   bplan_adr
    00123
    00128 #define VDP_WINDOW              WINDOW
    00129
    00132 #define VDP_PLAN_WINDOW         VDP_WINDOW
    00133
    00137 #define VDP_SCROLL_H            HSCRL
    00138
    00142 #define VDP_SPRITE_LIST         SLIST
    00143
    00147 #define VDP_PLAN_A              APLAN
    00148
    00152 #define VDP_PLAN_B              BPLAN
    00153
    00158 #define HSCROLL_PLANE           0
    00159
    00163 #define HSCROLL_TILE            2
    00164
    00168 #define HSCROLL_LINE            3
    00169
    00174 #define VSCROLL_PLANE           0
    00175
    00179 #define VSCROLL_2TILE           1
    00180
    00186 #define INTERLACED_NONE         0
    00187
    00192 #define INTERLACED_MODE1        1
    00193
    00198 #define INTERLACED_MODE2        2
    00199
    00204 #define TILE_SIZE               32
    00205 #define TILE_INDEX_MASK         (0xFFFF / TILE_SIZE)
    00206
    00211 #define TILE_SPACE              WINDOW
    00212
    00217 #define TILE_MAXNUM             (TILE_SPACE / TILE_SIZE)
    00218
    00222 #define TILE_MAXINDEX           (TILE_MAXNUM - 1)
    00223
    00227 #define TILE_SYSTEMINDEX        0x0000
    00228
    00232 #define TILE_SYSTEMLENGTH       0x10
    00233
    00236 #define TILE_SYSTEMLENGHT       TILE_SYSTEMLENGTH
    00237
    00241 #define TILE_USERINDEX          (TILE_SYSTEMINDEX + TILE_SYSTEMLENGTH)
    00242
    00246 #define TILE_FONTINDEX          (TILE_MAXNUM - FONT_LEN)
    00247
    00251 #define TILE_USERLENGTH         (TILE_FONTINDEX - TILE_USERINDEX)
    00252
    00255 #define TILE_USERLENGHT         TILE_USERLENGTH
    00256
    00260 #define TILE_USERMAXINDEX       (TILE_USERINDEX + TILE_USERLENGTH - 1)
    00261
    00265 #define TILE_SYSTEM             (TILE_SYSTEMINDEX * TILE_SIZE)
    00266
    00270 #define TILE_USER               (TILE_USERINDEX * TILE_SIZE)
    00271
    00275 #define TILE_FONT               (TILE_FONTINDEX * TILE_SIZE)
    00276
    00281 #define PAL0                    0
    00282
    00286 #define PAL1                    1
    00287
    00291 #define PAL2                    2
    00292
    00296 #define PAL3                    3
    00297
    00302 #define GFX_READ_VRAM_ADDR(adr)     ((0x0000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0x00)
    00303
    00307 #define GFX_READ_CRAM_ADDR(adr)     ((0x0000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0x20)
    00308
    00312 #define GFX_READ_VSRAM_ADDR(adr)    ((0x0000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0x10)
    00313
    00318 #define GFX_WRITE_VRAM_ADDR(adr)    ((0x4000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0x00)
    00319
    00323 #define GFX_WRITE_CRAM_ADDR(adr)    ((0xC000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0x00)
    00324
    00328 #define GFX_WRITE_VSRAM_ADDR(adr)   ((0x4000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0x10)
    00329
    00334 #define GFX_DMA_VRAM_ADDR(adr)      ((0x4000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0x80)
    00335
    00339 #define GFX_DMA_CRAM_ADDR(adr)      ((0xC000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0x80)
    00340
    00344 #define GFX_DMA_VSRAM_ADDR(adr)     ((0x4000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0x90)
    00345
    00350 #define GFX_DMA_VRAMCOPY_ADDR(adr)  ((0x4000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0xC0)
    00351
    00356 #define GFX_VERT_SCROLL(adr)        GFX_WRITE_VSRAM_ADDR(adr)
    00357
    00361 #define GFX_HORZ_SCROLL(adr)        GFX_WRITE_VRAM_ADDR(VDP_SCROLL_H + (adr))
    00362
    00367 #define GET_VDPSTATUS(flag)         ((*(vu16*)(GFX_CTRL_PORT)) & (flag))
    00368
    00372 #define IS_PALSYSTEM                GET_VDPSTATUS(VDP_PALMODE_FLAG)
    00373
    00378 #define GET_HVCOUNTER               (*(vu16*)(GFX_HVCOUNTER_PORT))
    00379
    00383 #define GET_HCOUNTER                (GET_HVCOUNTER & 0xFF)
    00384
    00388 #define GET_VCOUNTER                (GET_HVCOUNTER >> 8)
    00389
    00390
    00399 typedef struct
    00400 {
    00401     u16 v;
    00402 } VDPPlan;
    00403
    00404
    00405 extern const VDPPlan PLAN_B;
    00406 extern const VDPPlan PLAN_A;
    00407
    00408
    00409 // used by define
    00410 extern u16 window_adr;
    00411 extern u16 aplan_adr;
    00412 extern u16 bplan_adr;
    00413 extern u16 hscrl_adr;
    00414 extern u16 slist_adr;
    00415
    00420 extern u16 screenWidth;
    00425 extern u16 screenHeight;
    00426
    00427
    00434 void VDP_init();
    00435
    00444 u8   VDP_getReg(u16 reg);
    00454 void VDP_setReg(u16 reg, u8 value);
    00455
    00460 u8   VDP_getEnable();
    00467 void VDP_setEnable(u8 value);
    00468
    00475 u16  VDP_getScanlineNumber();
    00483 u16  VDP_getScreenHeight();
    00490 void VDP_setScreenHeight224();
    00497 void VDP_setScreenHeight240();
    00504 u16  VDP_getScreenWidth();
    00509 void VDP_setScreenWidth256();
    00514 void VDP_setScreenWidth320();
    00515
    00522 u16  VDP_getPlanWidth();
    00529 u16  VDP_getPlanHeight();
    00541 void VDP_setPlanSize(u16 w, u16 h);
    00542
    00551 u8 VDP_getHorizontalScrollingMode();
    00560 u8 VDP_getVerticalScrollingMode();
    00581 void VDP_setScrollingMode(u16 hscroll, u16 vscroll);
    00582
    00583
    00588 u8 VDP_getBackgroundColor();
    00593 void VDP_setBackgroundColor(u8 value);
    00594
    00599 u8   VDP_getAutoInc();
    00604 void VDP_setAutoInc(u8 value);
    00605
    00612 void VDP_setHInterrupt(u8 value);
    00617 void VDP_setHilightShadow(u8 value);
    00618
    00623 u8   VDP_getHIntCounter();
    00631 void VDP_setHIntCounter(u8 value);
    00632
    00637 u16 VDP_getAPlanAddress();
    00642 u16 VDP_getBPlanAddress();
    00647 u16 VDP_getWindowAddress();
    00652 u16 VDP_getWindowPlanAddress();
    00657 u16 VDP_getSpriteListAddress();
    00662 u16 VDP_getHScrollTableAddress();
    00663
    00679 void VDP_setAPlanAddress(u16 value);
    00695 void VDP_setWindowAddress(u16 value);
    00700 void VDP_setWindowPlanAddress(u16 value);
    00716 void VDP_setBPlanAddress(u16 value);
    00732 void VDP_setSpriteListAddress(u16 value);
    00748 void VDP_setHScrollTableAddress(u16 value);
    00749
    00762 void VDP_setScanMode(u16 mode);
    00763
    00768 void VDP_waitDMACompletion();
    00773 void VDP_waitFIFOEmpty();
    00774
    00781 void VDP_waitVSync();
    00782
    00789 void VDP_resetScreen();
    00790
    00791
    00802 void VDP_showFPS(u16 float_display);
    00803
    00804
    00805 #endif // _VDP_H_

All Classes Files Functions Variables Typedefs Enumerations Defines